package user

import (
	"gitcode.com/G-YT/iHealth25/server/global"
	"gitcode.com/G-YT/iHealth25/server/model/manager"
	"gitcode.com/G-YT/iHealth25/server/plugin/geo/model"
	"github.com/gofrs/uuid/v5"
	"time"
)

type Login interface {
	GetName() string
	GetUUID() uuid.UUID
	GetUserId() uint
	GetAuthorityId() uint
	GetUserInfo() any
}

var _ Login = new(User)

type User struct {
	global.GVA_MODEL
	UUID            uuid.UUID               `json:"uuid" gorm:"index;column:uuid;comment:用户UUID"`
	ServiceCenterID uint                    `json:"service_center_id" form:"serviceCenterID" gorm:"column:service_center_id;comment:服务站id"`
	StewardID       uint                    `json:"steward_id" form:"stewardID" gorm:"column:steward_id;comment:健管师id"`
	InviteUserID    uint                    `json:"invite_user_id" gorm:"column:invite_user_id;comment:邀请人id"`
	Phone           string                  `json:"phone" gorm:"column:phone;comment:用户手机号"`
	OpenID          string                  `json:"openID" gorm:"column:open_id;comment:微信OpenID"`
	Password        string                  `json:"password" gorm:"column:password;comment:登录密码"`
	Name            string                  `json:"name" form:"name" gorm:"column:name;comment:名称"`
	Avatar          string                  `json:"avatar" gorm:"column:avatar;default:https://image.cushdylm.com/app/default_avatar.jpg;comment:用户头像"`
	Types           uint                    `json:"types" gorm:"column:types;default:1;comment:用户类型 1用户 2会员 3过期会员"`
	Sex             uint                    `json:"sex" gorm:"column:sex;default:1;comment:性别 1男 2女"`
	Birthday        time.Time               `json:"birthday" gorm:"column:birthday;comment:生日"`
	Province        uint                    `json:"province" gorm:"column:province;comment:省"`
	City            uint                    `json:"city" gorm:"column:city;comment:市"`
	Area            uint                    `json:"area" gorm:"column:area;comment:区/县;"`
	Addr            string                  `json:"addr" gorm:"column:addr;comment:详细地址;"`
	Status          uint                    `json:"status" form:"status"  gorm:"column:status;comment:状态 正常1 冻结0;default:1;"`
	Points          uint                    `json:"points" form:"points"  gorm:"column:points;comment:积分;default:0;"`
	UrgentCard      UrgentCard              `json:"urgentCard" gorm:"foreignKey:ID;references:U_id;comment:用户紧急卡关联;"`
	Division        Division                `json:"division" gorm:"foreignKey:ID;references:ID;comment:用户段位关联;"`
	HealthManager   manager.FdHealthManager `json:"healthManager" gorm:"->;foreignKey:StewardID;references:HmId;"` //健管师相关
	ProvinceInfo    model.GeoProvince       `json:"provinceInfo" gorm:"->;foreignKey:Code;references:Province;"`   // 省关联
	CityInfo        model.GeoCity           `json:"cityInfo" gorm:"->;foreignKey:Code;references:City;"`           // 市关联
	AreaInfo        model.GeoArea           `json:"areaInfo" gorm:"->;foreignKey:Code;references:Area;"`           // 区关联
}

func (User) TableName() string {
	return "fd_user"
}

func (s *User) GetName() string {
	return s.Name
}

func (s *User) GetUUID() uuid.UUID {
	return s.UUID
}

func (s *User) GetUserId() uint {
	return s.ID
}

func (s *User) GetAuthorityId() uint {
	return 6666
}

func (s *User) GetUserInfo() any {
	return *s
}
